package com.coda.app.service.impl;

import com.coda.app.mapper.RegionMapper;
import com.coda.app.service.RegionService;
import com.coda.entity.CityInfo;
import com.coda.entity.DistrictInfo;
import com.coda.entity.ProvinceInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class RegionServiceImpl implements RegionService {

    @Autowired
    private RegionMapper regionMapper;
    /**
     * 查询省份列表
     * @return
     */
    @Override
    public List<ProvinceInfo> getProvince() {
        List<ProvinceInfo> provinceInfoList = regionMapper.getProvinceList();
        return provinceInfoList;
    }

    /**
     * 根据省份id查询城市列表
     * @param id
     * @return
     */
    @Override
    public List<CityInfo> getCityList(Long id) {
        List<CityInfo> cityInfoList = regionMapper.getCityList(id);
        return cityInfoList;
    }

    /**
     * 根据城市id查询县区列表
     * @param id
     * @return
     */
    @Override
    public List<DistrictInfo> getDistrictList(Long id) {
        List<DistrictInfo> districtInfoList = regionMapper.getDistrictList(id);
        return districtInfoList;
    }
}
